addLoadEvent(function() {
	/*
	if (!isXMLHTTPRequestSupported()) {
		alert("You much use a browser which supports the XmlHTTPRequest object. A full list of supported browsers is available on Auditionrocks.com");
		return false;
	}
	*/
	
	var co = document.getElementById("countries");
	var sp = document.getElementById("stateProvince");
	var ci = document.getElementById("city");
	var ve = document.getElementById("venue");
	var vel = document.getElementById("venueList");
	
	if (co) {
		co.onchange = function() {
			YAHOO.util.Dom.setStyle('stateProvince','opacity', 0.5);
			ar = YAHOO.util.Connect.asyncRequest('GET','xml/venues.xml.php?country=' + escape(co.value), {success: function(xm) {
				sps = xm.responseXML.getElementsByTagName("sp");
				
				sp.length = 0;
				sp.options[0] = new Option("** Select State/Province", "");
				for (i = 0; i < sps.length; i++) {
					thisID = sps[i].getAttribute("id");
					sp.options[sp.options.length] = new Option(sps[i].firstChild.nodeValue, thisID);
				}
				YAHOO.util.Dom.setStyle('stateProvince','opacity', 1.0);
			}});
		}
	}
	
	if (sp) {
		sp.onchange = function() {
			YAHOO.util.Dom.setStyle('city','opacity', 0.5);
			ar = YAHOO.util.Connect.asyncRequest('GET','xml/venues.xml.php?country=' + escape(co.value) + '&stateProvince=' + escape(sp.value), {success: function(xm) {
				cities = xm.responseXML.getElementsByTagName("city");
				ci.length = 0;
				ci.options[0] = new Option("** Select City", "");
				for (i = 0; i < cities.length; i++) {
					thisID = cities[i].getAttribute("id");
					ci.options[ci.options.length] = new Option(cities[i].firstChild.nodeValue, thisID);
				}
				YAHOO.util.Dom.setStyle('city','opacity', 1.0);
			}});
		}
	}
	
	if (ci) {
		ci.onchange = function() {
			if (ve) {
				YAHOO.util.Dom.setStyle('venue','opacity', 0.5);
			} else if (vel) {
				vel.innerHTML = "<strong>Loading...</strong>";
			}
			ar = YAHOO.util.Connect.asyncRequest('GET','xml/venues.xml.php?country=' + escape(co.value) + '&stateProvince=' + escape(sp.value) + '&city=' + escape(ci.value), {success: function(xm) {
				venues = xm.responseXML.getElementsByTagName("venue");
				if (ve) {
					ve.length = 0;				
					for (i = 0; i < venues.length; i++) {
						thisID = venues[i].getAttribute("id");
						ve.options[ve.options.length] = new Option(venues[i].firstChild.nodeValue, thisID);
					}
					ve.options[ve.options.length] = new Option("** No Venue", 0);
					YAHOO.util.Dom.setStyle('venue','opacity', 1.0);

				} else if (vel) {
					vel.innerHTML = "";
					for (i = 0; i < venues.length; i++) {
						vel.innerHTML += '<div class="venue"><a href="venue_edit.php?id=' + venues[i].getAttribute("id") + '">' + venues[i].firstChild.nodeValue + '</a></div>';
					}
				}
				
			}});
		}
	}
});
